package cn.xfdzx.android.apps.shop.presenter;

import cn.xfdzx.android.apps.shop.base.BasePresenter;
import cn.xfdzx.android.apps.shop.bean.IdCardBeen;
import cn.xfdzx.android.apps.shop.bean.LicenseImgBeen;
import cn.xfdzx.android.apps.shop.bean.OneBeen;
import cn.xfdzx.android.apps.shop.contract.IdCardContract;
import cn.xfdzx.android.apps.shop.contract.ShopInContract;
import cn.xfdzx.android.apps.shop.model.IdCardModel;
import cn.xfdzx.android.apps.shop.model.ShopInModel;
import cn.xfdzx.android.apps.shop.net.RxScheduler;
import io.reactivex.functions.Consumer;

/**
 * @author azheng
 * @date 2018/6/4.
 * Description：
 */
public class IdCardPresenter extends BasePresenter<IdCardContract.View> implements IdCardContract.Presenter {

    private IdCardContract.Model model;

    public IdCardPresenter() {
        model = new IdCardModel();
    }





    @Override
    public void idCardSubmit(String infoImg, String emblemImg) {
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.idCardSubmit(infoImg,emblemImg)
                .compose(RxScheduler.<IdCardBeen>Flo_io_main())
                .as(mView.<IdCardBeen>bindAutoDispose())
                .subscribe(new Consumer<IdCardBeen>() {
                    @Override
                    public void accept(IdCardBeen bean) throws Exception {
                        mView.onIdCardSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }
}
